#include <Elementary.h>

/* return value of app - keep it here so we can modify it */
static int retval = -1;

/* if someone presses the close button on our window - exit nicely */
	static void
win_del(void *data, Evas_Object *obj, void *event_info)
{
	retval = -1;
	/* cleanly exit */
	elm_exit();
}

/* when ok is pressed this runs */
	static void
on_ok(void *data, Evas_Object *obj, void *event_info)
{
	retval = 0;
	/* cleanly exit */
	elm_exit();
}

/* when cancel is pressed this runs */
	static void
on_cancel(void *data, Evas_Object *obj, void *event_info)
{
	retval = -1;
	/* cleanly exit */
	elm_exit();
}

	EAPI int
elm_main(int argc, char **argv)
{
	Evas_Object *win, *bg, *bx, *lb, *li, *bt, *bx2, *fr, *fr0;
	const char *text = "No text provided";

	/* if an argument is there - use it as text */
	if (argc > 1) text = argv[1];

	/* new window - do the usual and give it a name, title and delete handler */
	win = elm_win_add(NULL, "dialog", ELM_WIN_BASIC);
	elm_win_title_set(win, "Dialog");
	evas_object_smart_callback_add(win, "delete,request", win_del, NULL);

	/* add a standard bg */
	bg = elm_bg_add(win);
	/* not not allow bg to expand. let's limit dialog size to contents */
	evas_object_size_hint_weight_set(bg, 0.0, 0.0);
	elm_win_resize_object_add(win, bg);
	evas_object_show(bg);

	/* add a box object - default is vertical. a box holds children in a row,
	 * either horizontally or vertically. nothing more. */
	bx = elm_box_add(win);
	/* not not allow box to expand. let's limit dialog size to contents */
	evas_object_size_hint_weight_set(bx, 0.0, 0.0);
	elm_win_resize_object_add(win, bx);
	evas_object_show(bx);

	/* add a padding frame - empty space. large padding. themes can cary
	 * the amount of padding, as can scaling, so don't depend on your pixel
	 * cound here. add pad frame to box */
	fr = elm_frame_add(win);
	elm_frame_style_set(fr, "pad_large");
	/* dont expand */
	evas_object_size_hint_weight_set(fr, 0.0, 0.0);
	/* fill allocated region */
	evas_object_size_hint_align_set(fr, -1.0, -1.0);
	elm_box_pack_end(bx, fr);
	evas_object_show(fr);

	/* add a label widget, set the text and put it in the pad frame */
	lb = elm_label_add(win);
	elm_label_label_set(lb, text);
	elm_frame_content_set(fr, lb);
	evas_object_show(lb);

	/* add another styled frame - outdent_bottom now */
	fr0 = elm_frame_add(win);
	elm_frame_style_set(fr0, "outdent_bottom");
	/* dont expand */

	evas_object_size_hint_weight_set(fr0, 0.0, 0.0);
	/* fill allocated region */
	evas_object_size_hint_align_set(fr0, -1.0, -1.0);
	elm_box_pack_end(bx, fr0);
	evas_object_show(fr0);

	/* add medium pad frame inside outdent frame */
	fr = elm_frame_add(win);
	elm_frame_style_set(fr, "pad_medium");
	elm_frame_content_set(fr0, fr);
	evas_object_show(fr);

	/* add horizontal box inside pad frame */
	bx2 = elm_box_add(win);
	elm_box_horizontal_set(bx2, 1);
	elm_box_homogenous_set(bx2, 1);
	elm_frame_content_set(fr, bx2);
	evas_object_show(bx2);

	/* add ok button to box - fill and expand */
	bt = elm_button_add(win);
	elm_button_label_set(bt, "OK");
	evas_object_size_hint_weight_set(bt, 1.0, 1.0);
	evas_object_size_hint_align_set(bt, -1.0, -1.0);
	elm_box_pack_end(bx2, bt);
	evas_object_show(bt);
	/* and when clicked - run "on_ok" */
	evas_object_smart_callback_add(bt, "clicked", on_ok, NULL);

	/* add cancel button to box - fill and expand */
	bt = elm_button_add(win);
	elm_button_label_set(bt, "Cancel");
	evas_object_size_hint_weight_set(bt, 1.0, 1.0);
	evas_object_size_hint_align_set(bt, -1.0, -1.0);
	elm_box_pack_end(bx2, bt);
	evas_object_show(bt);
	/* and when clicked - run "on_cancel" */
	evas_object_smart_callback_add(bt, "clicked", on_cancel, NULL);

	/* show the window */
	evas_object_show(win);

	/* get going and draw/respond to the user */
	elm_run();
	/* standard shutdown */
	elm_shutdown();
	/* return/exit code of app signals ok/cancel (0 == ok), (-1 == cancel) */
	return retval;
}
ELM_MAIN()
